#define  _CRT_SECURE_NO_WARNINGS
#include <iostream>
using namespace std;
const int N = 100010;
long long arr[N], dp[N];
int n, q;
int main()
{
	cin >> n >> q;


	for (int i = 1; i <= n; i++) cin >> arr[i];


	for (int i = 1; i <= n; i++) dp[i] = dp[i - 1] + arr[i];
	while (q--)
	{
		int l, r;
		cin >> l >> r;


		cout << dp[r] - dp[l - 1] << endl;
	}
	return 0;
}